<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/1/28
 * Time: 20:44
 */
/**
 *    获取分类
 */
namespace kkw\admin\response;
use kkw\user\Util;
use kkw\admin\table\GoodsTypeTable;
use suda\core\Request;
use suda\core\Response;

class EarnTypeResponse extends  Response
{

    public function onRequest(Request $request)
    {
        // 设置请求头
        Util::printHeader();
        $goods_type = new GoodsTypeTable();
        // 获取前台请求数据
//        $json = Request::json();
//        $user_id=session()->get('user.id');
//        ,['id'=> $user_id]
        try {
            $goodstypedata = $goods_type->list();
        } catch (\suda\exception\SQLException $e) {
            $this->json([
                "code"=>1,
                "message"=>"请求失败"
            ]);
        }
        $this->json([
            "code"=>0,
            "data"=> $goodstypedata
        ]);
    }
}